package ocp

import (
    `net/http`
    `strconv`
)

// 霰弹式修改

func GetUserHandlerV1(resp http.ResponseWriter, req *http.Request) {
    // validate inputs
    err := req.ParseForm()
    if err != nil {
        resp.WriteHeader(http.StatusInternalServerError)
        return
    }
    userID, err := strconv.ParseInt(req.Form.Get("UserID"), 10, 64)
    if err != nil {
        resp.WriteHeader(http.StatusPreconditionFailed)
        return
    }

    user := loadUser(userID)
    outputUser(resp, user)
}

func DeleteUserHandlerV1(w http.ResponseWriter, r *http.Request) {
    // validate inputs
    err := r.ParseForm()
    if err != nil {
        w.WriteHeader(http.StatusInternalServerError)
        return
    }

    userID, err := strconv.ParseInt(r.Form.Get("userID"), 10, 64)
    if err != nil {
        w.WriteHeader(http.StatusInternalServerError)
        return
    }

    deleteUser(userID)
}

func loadUser(userID int64) interface{} {
    // TODO: implement
    return nil
}

func deleteUser(userID int64) {
    // todo

}

func outputUser(w http.ResponseWriter, user interface{}) {
    // todo
}
